/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.serli.sample.person.model.service.ws;

import com.serli.sample.person.model.data.Gender;
import com.serli.sample.person.model.data.Person;
import com.serli.sample.person.model.data.session.PeopleBeanLocal;
import java.text.ParseException;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.Style;

/**
 *
 * @author serli
 */
@WebService ( name = "PeopleService-WS", serviceName= "PeopleService", wsdlLocation="WEB-INF/wsdl/PeopleService.wsdl")
public class PeopleService  implements com.serli.sample.person.model.service.PeopleServiceRemote
{
    
    @EJB (name = "people-model-ear-1.1/PeopleBean/local")
    PeopleBeanLocal peopleBean;

    @WebMethod(operationName = "insert")
    @Oneway
    public void insert(Person person) {
        peopleBean.insert(person);
    }

    @WebMethod(operationName = "delete")
    @Oneway
    public void delete(Person person) {
        peopleBean.delete(person);
    }

    @WebMethod(operationName = "getAllOrderByFirstName")
    @WebResult//(name = "listPerson")
    public List<Person> getAllOrderByFirstName() {
        return peopleBean.getAllOrderByFirstName();
    }

    @WebMethod(operationName="testRemoteSetPerson")
    @Oneway
    public void testRemoteSetPerson(Person person) {
        System.out.println(person.toString());
    }

    @WebMethod(operationName="testRemoteGetPerson")
    public Person testRemoteGetPerson() {
        Person p = null;
        try {
            p = new Person("TestFirstName-ws", "TestLastName-ws", "1999-6-15", Gender.MALE);
        } catch (ParseException ex) {
            Logger.getLogger(PeopleService.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        return p;
    }

    @WebMethod(operationName="testRemoteObject")
    public Object testRemoteObject(Object obj) {
        return obj;
    }

    @WebMethod(operationName="testRemotePrimitif")
    public int testRemotePrimitif(int i) {
        return i;
    }
}
